//
//  ViewController.m
//  JKTest2
//
//  Created by 王冲 on 2019/4/28.
//  Copyright © 2019 JK科技有限公司. All rights reserved.
//

#import "ViewController.h"

#import "JKSegementController.h"
#import "ViewController1.h"
#import "ViewController2.h"
@interface ViewController ()
{
    JKSegementController *segement;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(10, 0, JKNaviHeight, JKNaviHeight)];
    [button setBackgroundColor:JKRandomColor];
    [button addTarget:segement action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    ViewController1 *vc1 = [ViewController1 new];
    
    ViewController2 *vc2 = [ViewController2 new];
    
    segement = [JKSegementController segementControllerWithFrame:CGRectMake(0,JKNaviHeight, JK_SCREEN_WIDTH,JK_SCREEN_HEIGHT-JKNaviHeight) titles:@[@"待办",@"已办"]];
    [segement setSegementViewControllers:@[vc1,vc2]];
    [segement setSegementTintColor:[UIColor greenColor]];
    [segement setSelectedItemAtIndex:0];
    segement.style = JKSegementStyleDefault;
    [segement selectedAtIndex:^(NSInteger index) {
        
        NSLog(@"当前选择的index === %ld",index);
    }];
    [self.view addSubview:segement.view];
    [self addChildViewController:segement];
}

-(void)click{
    
    [segement updateTittle:@[@"待办(2)",@"已办(7)"]];
    // [segement setSegementTintColor:[UIColor greenColor]];
}

@end
